#include<cstdio>//uncle-lu
#include<cstring>
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

int n, m;
long long int line[110];
long long int F[100][100];
long long int ans;

int main()
{
	read(n);read(m);

	for (int i = 1; i <= n; i++) 
	{
		for (int j = 1; j <= m; j++) 
			read(line[j]);

		memset(F, 0, sizeof(F));
		for (int len = m-1; len >= 1; len--) 
		{
			for (int l = 1; l <= m - len + 1; l++) 
			{
				int r = l + len - 1;
				F[l][r] = std::max(F[l][r], F[l-1][r] + line[l-1] * (1LL << (m-len)) );
				F[l][r] = std::max(F[l][r], F[l][r+1] + line[r+1] *(1LL << (m-len)) );
			}
		}
		
		long long int mx = 0;
		for (int j = 1; j <= m; j++) 
			mx = std::max(mx, F[j][j] + (1 << m) * line[j]);

		ans += mx;
	}

	printf("%lld", ans);
	return 0;
}
